package org.example.validation.handlers;


import org.example.validation.ValidatorContext;
import org.example.validation.ValidatorHandler;

public class MinValidatorHandler implements ValidatorHandler {

    private int min;

    public MinValidatorHandler(int min) {
        this.min = min;
    }

    @Override
    public void validate(Object obj, ValidatorContext context) {
        //所校验字段必须是int 类型
        if(obj instanceof Integer ){
            if((Integer) obj < min){
                context.addErrorMessage("字段值不能小于"+min);
            }
        }
    }
}
